package br.com.rookgraph.utils;

import br.com.rookgraph.Graph;

public enum EnumGeracaoArvore {

	LARGURA("Largura") {
		@Override
		public Graph getTree(Graph graph, int root) {
			return graph.getTreeLarge(new Graph(graph.getOrder()), root);
		}
	},
	
	PRODUNDIDADE("Profundidade") {
		@Override
		public Graph getTree(Graph graph, int root) {
			return graph.getTreeDepth(new Graph(graph.getOrder()), root);
		}
	},
	
	KRUSKAL("Kruskal-Wallis") {
		@Override
		public Graph getTree(Graph graph, int root) {
			return graph.getTreeKruskal(new Graph(graph.getOrder()));
		}
	
	};
	
	private String descricao;
	
	EnumGeracaoArvore(String descricao) {
		this.descricao = descricao;
	}
	
	public String getDescricao() {
		return this.descricao;
	}
	
	public abstract Graph getTree(Graph graph, int root);

	@Override
	public String toString() {
		return descricao;
	}
	
	public static EnumGeracaoArvore buscarValorPorNome(String nome) {
		for (EnumGeracaoArvore v : EnumGeracaoArvore.values()) {
			if (v.getDescricao().equalsIgnoreCase(nome)) {
				return v;
			}
		}
		
		return null;
	}
	
}
